package com.example.wanandroid_copy2.ui.search.dao

import androidx.lifecycle.MutableLiveData
import com.example.wanandroid_copy2.common.BaseObserver
import com.example.wanandroid_copy2.common.BaseResponse
import com.example.wanandroid_copy2.common.api.ApiRepository
import com.example.wanandroid_copy2.common.network.State
import com.example.wanandroid_copy2.common.utils.execute
import com.example.wanandroid_copy2.ui.article.data.ArticleRepository
import com.example.wanandroid_copy2.ui.search.dao.HotSearchRsp
import com.example.wanandroid_copy2.ui.search.dao.SearchResultRsp

/**
 * @author Laizexin on 2019/12/11
 * @description
 */
class SearchRepository(loadState: MutableLiveData<State>) : ArticleRepository(loadState) {

    fun search(page: Int, str: String, liveData: MutableLiveData<BaseResponse<SearchResultRsp>>) {
        apiService.search(page, str).execute(BaseObserver(liveData, loadState, this))
    }

    fun getHotSearch(liveData: MutableLiveData<BaseResponse<List<HotSearchRsp>>>) {
        apiService.getHotKey().execute(BaseObserver(liveData, loadState, this))
    }

}